<%--
  Created by IntelliJ IDEA.
  User: 王殿鑫
  Date: 2021/5/6
  Time: 18:41
  To change this template use File | Settings | File Templates.
--%>
<?xml version="1.0" encoding="UTF-8" ?>
<%@ page language="java" contentType="text/html; charset=utf-8"  isELIgnored="false"
         pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <title>宠物商城</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<style type="text/css">
    *{
        margin: 0 auto;
    }
    a{
        text-decoration:none;
        color: black;
    }
</style>
<body>
<div class="" style="width: 1200px; height: 100px; background-color: lightcyan; margin-top: 10px;">

    <div class="" style="position: relative;width: 300px;height:30px;  margin-left: 150px; padding-top:45px;">
        <span>类别</span>
        <select id="skills" name="skills"  style="width:120px;height: 35px;margin-left:15px;">
            <option value="1">狗狗</option>
            <option value="2">猫猫</option>
            <option value="3">鱼儿</option>
            <option value="4">其它</option>
        </select>
        <button onclick="findGoodById()"> 查询</button>
    </div>

    <c:if test="${empty clientUser}">
        <div style="width: 100px; height: 30px;margin-right: 20px;margin-top: -30px;">
            <a href="register.jsp" >注册</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <a href="login.jsp">登录</a>
        </div>
    </c:if>
    <c:if test="${! empty clientUser}">
        <div style="width: 100px; height: 30px;margin-right: 20px;margin-top: -30px;">
            <a>${clientUser.username}</a>&nbsp;&nbsp;
            <a href="FindCarAll?userid=${clientUser.userid}">购物车</a>
        </div>
    </c:if>
</div>
<div style="height: 20px;width: 1200px"></div>
<hr style="border: none;border-top: 2px dotted #87CEEB"/>
<c:forEach items="${goodsList}" var="good">
    <div class="" style="margin-left: 220px;">
        <div id="" style="width: 300px; height: 235px; float: left; margin-left: 30px; margin-top: 15px;border:1px solid #C8C8C8">
            <img src="img${good.detail}" style="width: 150px;height: 150px; margin-left: 80px;margin-top: 10px;">
            <a href="findGoodById?goodsid=${good.goodsid}" style="display: block; width: 90px; height: 20px; margin-top: 5px;text-align: center;font-size: 18px" >${good.goodsname}</a>
            <a href="GoodAddCar?goodsid=${good.goodsid}&userid=${clientUser.userid}&price=${good.price}" style="display: block; width: 200px; height: 20px; margin-top: 10px;text-align: center;" >
                <button class="" style="background-color: #87CEEB;font-size: 18px;color: white;border-radius: 25px;border-color:#87CEEB">加入购物车</button>
            </a>
        </div>

    </div>
</c:forEach>
</body>

<script>
    function findGoodById(){
        var myselect= document.getElementById("skills");
        var index=myselect.selectedIndex;
        var x = myselect.options[index].value;
        location.href="findAllGoodsByKind?kind="+x;
    }
</script>
</html>